feat: update from origin/main without altering local branches#113
Closed
guplem wants to merge 1 commit into
Closed
feat: update from origin/main without altering local branches#113guplem wants to merge 1 commit into
guplem wants to merge 1 commit into
Conversation
2 tasks
58bc6b5 to
ed316c1
Compare
Instead of merging the local default branch (e.g. `main`), merge the remote tracking branch (e.g. `origin/main`) after fetching. This avoids altering local branches as a side effect of the update operation. - Fetch without fast-forwarding local branches before merging - Find and merge the remote tracking branch instead of the local one - Update the menu label to show the remote ref (e.g. "Update from origin/main") Follow-up to PR desktop#111 as suggested by @pol-rivero. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
4ca527b to
9067ba3
Compare
Owner
|
This looks promising. I'll have a closer look later today |
Owner
Author
|
Uoops, I might have done something wrong, obviously… but yeah, I agree with you that this is probably not necessary. I was just trying to make everyone happy :) So yeah, I am closing this PR then. |
Owner
|
Thanks for understanding ❤️ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Summary
Follow-up to #111 as suggested by @pol-rivero.
After PR #111 added a fetch before the merge,
performFetchalso fast-forwards local branches as a side effect.By merging
origin/main directly(instead of local main) and skipping the fast-forward step, we avoid unintended changes to local branches.So, instead of merging the local default branch (e.g.
main), with this PR it merges the remote tracking branch (e.g.origin/main) directly. This means the "Update from Default Branch" action no longer alters local branches as a side effect. The menu label now reflects this (e.g. "Update from origin/main").Changes
app/src/ui/app.tsxupdateBranchWithContributionTargetBranch()asyncso it canawaitthe fetch before merging.origin/main) fromallBranchesand merges that instead of the local branch. Falls back to the local branch if no remote tracking branch is found.getRemoteTrackingBranch()helper: for remote branches (fork case) returns the branch as-is; for local branches, looks up the corresponding remote branch via theupstreamfield.app/src/ui/dispatcher/dispatcher.tsfetchWithoutFastForward(): exposes the new app-store method to the UI layer.app/src/lib/stores/app-store.tsskipFastForwardparameter toperformFetch(). Whentrue, skips thefastForwardBranches()call so local branches are not altered._fetchWithoutFastForward()public method that callsperformFetchwithskipFastForward: true.upstreamname (e.g.origin/main) instead of the local name (e.g.main), so the menu reads "Update from origin/main".Test plan
mainbranch is NOT fast-forwarded after the operation.